package com.iplant.aps.service.mesenum;

import com.iplant.aps.service.po.cfg.CFGItem;

import java.util.ArrayList;
import java.util.List;

/**
 * 退料单状态
 * 
 * @author YouWang·Peng
 * @CreateTime 2022-3-24 14:38:53
 *
 */
public enum MESMaterialReturnStatus {
	/**
	 * 保存
	 */
	Default(0, "保存"),
	/**
	 * 保存
	 */
	Saved(1, "保存"),
	/**
	 * 推送成功
	 */
	Sended(2, "推送成功"),
	/**
	 * 已退料
	 */
	Backed(3, "已退料"),
	/**
	 * 已完成
	 */
	Finished(20, "已完成"),
	/**
	 *已退料交接
	 */
	Handover(25,"已入库"),
	/**
	 * 已驳回
	 */
	Rejected(21, "已驳回"),
	/**
	 * 已关闭
	 */
	Canceled(22, "已关闭");

	private int value;
	private String lable;

	private MESMaterialReturnStatus(int value, String lable) {
		this.value = value;
		this.lable = lable;
	}

	/**
	 * 通过 value 的数值获取枚举实例
	 *
	 * @param val
	 * @return
	 */
	public static MESMaterialReturnStatus getEnumType(int val) {
		for (MESMaterialReturnStatus type : MESMaterialReturnStatus.values()) {
			if (type.getValue() == val) {
				return type;
			}
		}
		return MESMaterialReturnStatus.Default;
	}

	public static List<CFGItem> getEnumList() {
		List<CFGItem> wItemList = new ArrayList<CFGItem>();

		for (MESMaterialReturnStatus type : MESMaterialReturnStatus.values()) {
			CFGItem wItem = new CFGItem();
			wItem.ID = type.getValue();
			wItem.ItemName = type.getLable();
			wItem.ItemText = type.getLable();
			wItemList.add(wItem);
		}
		return wItemList;
	}

	public int getValue() {
		return value;
	}

	public String getLable() {
		return lable;
	}
}
